<?php

namespace App\Http\Requests\Counter;

use App\Enums\TableType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Enum;

class TableTypeRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'type' => [
                'required', new Enum(TableType::class)
            ],
            'name' => 'required',
            'start_num' => [
                'exclude_if:type,'.TableType::Room->value,
                'required'
            ],
//            'default_people_count' => [
//                'exclude_if:type,'.TableType::Room->value,
//                'required', 'min:1', 'integer'
//            ],
            'count' => [
                'exclude_if:type,'.TableType::Room->value,
                'required', 'min:1', 'integer'
            ],
            'tables' => [
                'exclude_if:type,'.TableType::Scattered->value,
                'required', 'array', 'min:1'
            ],
            'cost_rule_ids' => 'required|array|min:1',
            'default_rule_id' => 'required|integer|min:1'
        ];
    }
}
